/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2024-02-28
 * Time:8:22
 */
public class Solution {
    public int minStartValue(int[] nums) {
        int[] sum = new int[nums.length+1];
        int min = Integer.MAX_VALUE;
        for(int i = 1;i < sum.length;i++) {
            sum[i] = sum[i-1] + nums[i-1];
            min = Math.min(sum[i],min);
        }
        if(min >= 1) return 1;
        return 1-min;
    }
}
